
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background-color: salmon;
        }
    </style>
</head>

<body>
    <div></div>
    <button>x</button>
</body>
<script>
    var div1 = document.querySelector('div')
    var bon = document.querySelector('button')
    var flag = true
    bon.onclick = function(){
        if(flag==true){
            div1.style = 'display:none'
            flag = false
        }else{
            div1.style = 'display:flex'
            flag = true
        }
    }
</script>
</html>